from django.db import models

from account.models import UserProfile
from course.models import Course
from utils.models import TimeStampedModel


class UserConsultation(TimeStampedModel):
    """
    用户课程咨询
    """
    name = models.CharField(max_length=20, verbose_name='姓名')
    telephone = models.CharField(max_length=11, verbose_name='手机号')
    course = models.CharField(max_length=50, verbose_name='课程名')

    class Meta:
        verbose_name = '用户课程咨询'
        verbose_name_plural = verbose_name


class UserComment(TimeStampedModel):
    """
    用户课程评论
    """
    user = models.ForeignKey(UserProfile, verbose_name='用户', on_delete=True)
    course = models.ForeignKey(Course, verbose_name='课程', on_delete=True)
    comment = models.CharField(max_length=200, verbose_name='评论')

    class Meta:
        verbose_name = '用户课程评论'
        verbose_name_plural = verbose_name


class UserFavorite(TimeStampedModel):
    """
    用户收藏
    """
    FAVORITE_TYPE_CHOICES = (
        (1, '课程'),
        (2, '课程机构'),
        (3, '讲师')
    )
    user = models.ForeignKey(UserProfile, verbose_name='用户', on_delete=True)
    favorite_id = models.IntegerField(default=0, verbose_name='收藏id')
    favorite_type = models.CharField(choices=FAVORITE_TYPE_CHOICES, max_length=1, default=1, verbose_name='收藏类型')

    class Meta:
        verbose_name = '用户收藏'
        verbose_name_plural = verbose_name


class UserMessage(TimeStampedModel):
    """
    用户消息
    """
    user = models.IntegerField(default=0, verbose_name='接受用户')
    message = models.CharField(max_length=500, verbose_name='消息内容')
    has_read = models.BooleanField(default=False, verbose_name='是否已读')

    class Meta:
        verbose_name = '用户消息'
        verbose_name_plural = verbose_name


class UserCourse(TimeStampedModel):
    user = models.ForeignKey(UserProfile, verbose_name='用户', on_delete=True)
    course = models.ForeignKey(Course, verbose_name='课程', on_delete=True)

    class Meta:
        verbose_name = '用户消息'
        verbose_name_plural = verbose_name
